#ifndef __LDX_CSHADERCACHE_H_INCLUDE__	
#define __LDX_CSHADERCACHE_H_INCLUDE__
#include "PublicShaderDefines.h"
#include "mathtools\mathtools.h"

namespace ldx
{
	namespace render
	{
		class CRenderDriverD3D11;
		//Used to manager the shaders,including compailer
		//life time.
		class CShadersCache
		{
		public:

			CShadersCache(CRenderDriverD3D11* driver);

			~CShadersCache();

			int addShader(mt::wchar* filename, char* entryport, E_SHADER_TYPE type, SShaderMid& mid,mt::uint layeroutcount=0, D3D11_INPUT_ELEMENT_DESC* descs = 0);

			int addShader(mt::wchar* filename, char* entryport, E_SHADER_TYPE type, void** outShader, mt::uint layeroutcount = 0, D3D11_INPUT_ELEMENT_DESC* descs = 0);

			SShaderMid getShader(std::wstring name);

			bool isShaderExist(std::wstring& name);

		private:

			int compilerShader(mt::wchar* filename, char* entryport, E_SHADER_TYPE type,
				SShaderMid& mid,int layoutElements = 0, D3D11_INPUT_ELEMENT_DESC* layouts = 0);

			void insertShader(std::wstring& name,SShaderMid& mid);

			void clearShaders();

			void deleteShader(SShaderMid& mid);

			std::unordered_map<std::wstring, SShaderMid> HashMapOfShaders;

			CRenderDriverD3D11* Driver;
		};
	}
}
#endif//! __LDX_CSHADERCACHE_H_INCLUDE__